package com.rpay.common.util.http.builder;


import com.rpay.common.util.http.exception.HttpProcessException;

import java.util.concurrent.*;

public class HttpExecutorBuilder {

    private static ExecutorService fixedThreadPool = null;
    private static HttpExecutorBuilder instance = null;
    public static HttpExecutorBuilder custom() throws HttpProcessException {
        if (instance==null && fixedThreadPool==null) {
            instance = new HttpExecutorBuilder();
            fixedThreadPool = Executors.newFixedThreadPool(3);
        }
        return instance;
    }

    public <T> Future<T> submit(Callable<T> callable) {
        return fixedThreadPool.submit(callable);
    }

    public void execute(Runnable runnable) {
        fixedThreadPool.execute(runnable);
    }
}
